import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/Login'
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import My from '@/views/My'
import Detail from '@/views/Detail'
import Edit from '@/views/My/Edit'
import Search from '@/views/Search'
import SearchResult from '@/views/Search/searchResult'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    component: Login
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '',
        component: Home
      },
      // 目标: 我们想一上来默认就把二级路由home显示出来，并且tab的首页位置为激活的状态
      // 步骤:
      // 把home路由的path置空
      // van-tabbar-item组件的 to 属性 设置为 '/'
      // active属性 的默认值 设置为 home的路径 '/home'
      {
        path: 'my',
        component: My
      },
      {
        path: '/search',
        component: Search
      }
    ]
  },
  // 详情路由
  {
    path: '/detail',
    component: Detail
  },
  {
    path: '/edit',
    component: Edit
  },
  {
    path: '/searchResult',
    component: SearchResult
  }

]

const router = new VueRouter({
  routes
})

export default router
